#lang racket


(require "matrix.rkt"
         "point.rkt")


(provide m*p)

; edit: duplicated from matrix module
(define (v*v v1 v2)
  (foldl + 0 (vector->list (vector-map * v1 v2))))

; edit: should not give the user the option of separating points and vectors
(define (m*p m p (vector? #f))
  (let* ((w (if vector? 0 1))
         (v (vector (x p) (y p) (z p) w)))
    (xyz
     (v*v (m.line m 0) v)
     (v*v (m.line m 1) v)
     (v*v (m.line m 2) v))))